<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"  xml:lang="zh-CN" lang="zh-CN">
<head>
<title>留言本 注册</title>
<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
<link href="css/global.css" rel="stylesheet" type="text/css" />
<script language="JavaScript">
  <!--
	
	var eInterval;
	var loong_status;
	var intervalCount;
	var maxIntervalCount;
	
	eInterval        = false;
	loong_status     = -1;
	intervalCount    = 0;
	maxIntervalCount = 100;
	
	var http_response_t = {
		HTTP_RESPONSE_TIMEOUT              : 0,
		HTTP_RESPONSE_SIGN_NO              : 1,
		HTTP_RESPONSE_EMAIL_NO             : 2,
		HTTP_RESPONSE_EMAIL_OK             : 3,
		HTTP_RESPONSE_LOGIN_OK             : 4,
		HTTP_RESPONSE_DB_ERROR             : 5,
		HTTP_RESPONSE_LOGOUT_OK            : 6,
		HTTP_RESPONSE_DELETE_OK            : 7,
		HTTP_RESPONSE_DELETE_NO            : 8,
		HTTP_RESPONSE_UPDATE_OK            : 9,
		HTTP_RESPONSE_REGISTER_OK          : 10,
		HTTP_RESPONSE_VALIDATE_NO          : 11,
		HTTP_RESPONSE_VALIDATE_OK          : 12,
		HTTP_RESPONSE_USERNAME_NO          : 13,
		HTTP_RESPONSE_USERNAME_OK          : 14,
		HTTP_RESPONSE_PASSWORD_NO          : 15,
		HTTP_RESPONSE_CACHE_ERROR          : 16,
		HTTP_RESPONSE_EMAIL_EXISTS         : 17,
		HTTP_RESPONSE_UNKNOWN_TYPE         : 18,
		HTTP_RESPONSE_VARIABLE_ERROR       : 19,
		HTTP_RESPONSE_UNKNOWN_MODULE       : 20,
		HTTP_RESPONSE_USERNAME_EXISTS      : 21,
		HTTP_RESPONSE_SITE_NOT_EXISTS      : 22,
		HTTP_RESPONSE_EMAIL_NOT_EXISTS     : 23,
		HTTP_RESPONSE_USERNAME_NOT_EXISTS  : 24
	};

	function is_code(code)
	{
		var i, c;
		if(code.length != 4)
		{
			alert("验证码是四位的");
			return false;
		}
		for(i=0; i < code.length; i++)
		{
			c = code.charAt(i);
			if( (c < "0" || c > "9") && (c < "a" || c > "z" ) && (c < "A" || c > "Z" ))
			{
				alert("验证码必须由小写字母或数字组成");
				return false;
			}
		}
		return true;
	}
	
	function is_password(str)
	{
		var i, c;
		if(str.length < 5 || str.length > 19)
		{
			alert("密码是6位以上,20位以上");
			return false;
		}
		for(i=0; i < str.length; i++)
		{
			c = str.charAt(i);
			if( (c < "0" || c > "9") && (c < "a" || c > "z" ) && (c < "A" || c > "Z" ))
			{
				alert("密码必须由小写字母或数字组成");
				return false;
			}
		}
		return true;
	}

	function match_password(pass1, pass2)
	{
		if(pass1 != pass2)
		{
			alert("两次输入的密码不一样,请重新输入");
			return false;
		}
		return true;
	}


	function isEmail(strEmail) 
	{
		if (strEmail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
		{
			return true;
		}

		alert("电子邮件验证失败");
		return false;
	}

	function is_username(username)
	{
		var patrn = /^[a-zA-Z0-9\u4e00-\u9fa5]{2,20}$/; 


		if(!patrn.exec(username))
		{
			alert("用户名必须由中文\英文\数字");
			return false;
		}

		return true;
	}

	function loginIntervalProc()
	{
		var frm;

        if (loong_status == -1 && intervalCount < maxIntervalCount)
        {
            intervalCount++;
            return ;
        }
		
		switch (loong_status)
		{
			case http_response_t.HTTP_RESPONSE_EMAIL_EXISTS :
				alert("email 已存在");
				break;
			case http_response_t.HTTP_RESPONSE_USERNAME_EXISTS :
				alert("用户名 已存在");
				break;
			case http_response_t.HTTP_RESPONSE_USERNAME_NO :
				alert("用户名验证失败");
				break;
			case http_response_t.HTTP_RESPONSE_EMAIL_NO :
				alert("电子邮件验证失败");
				break;
			case http_response_t.HTTP_RESPONSE_PASSWORD_NO :
				alert("密码验证失败");
				break;
			case http_response_t.HTTP_RESPONSE_VALIDATE_NO :
				alert("验证码错误");
				break;
			case http_response_t.HTTP_RESPONSE_REGISTER_OK :
				alert("注册成功");
				window.location.href = "http://www.xxxabc.cn:8080/index.php";
				break;
			default:
				alert("验证超时");
		}
		
		frm = document.forms["loginform"];
		frm.elements["sub"].disabled = false;
		frm.elements["sub"].value    = "注册";

		clearInterval(eInterval);
		intervalCount = 0;
        eInterval     = false;
		login_status  = -1;
	}

	function load_script(url)
	{
		var newScript  = document.createElement("script");
		newScript.type = "text/javascript";
        newScript.src  = url + "&rand=" + Math.random();

		document.getElementsByTagName("head")[0].appendChild(newScript);
	}


	function disposal()
	{
		var url, frm, rc;
		frm  = document.forms["loginform"];

		rc = is_username(frm.elements["username"].value);
		if(!rc) return false;
		
		rc = is_password(frm.elements["password"].value);
		if(!rc) return false;
		
		rc = match_password(frm.elements["password"].value, frm.elements["pass"].value);
		if(!rc) return false;
		
		rc = isEmail(frm.elements["email"].value);
		if(!rc) return false;

		rc = is_code(frm.elements["code"].value);
		if(!rc) return false;


		url  = "http://www.loongsso.com:7171/?module=register&code=" + frm.elements["code"].value + "&username=" + frm.elements["username"].value + "&password=" + frm.elements["password"].value + "&email=" + frm.elements["email"].value;
		load_script(url);
		
		frm.elements["sub"].disabled = true;
		frm.elements["sub"].value    = "正在注册中,请等一下....";

	    eInterval = setInterval(function()
        {
            loginIntervalProc();
        }
        , 100);

		return false;
	}
  //-->
  </script>
</head>
<body>

<!-- 头部 -->
<div class="top">
	<div class="l">
		<img src="images/logo.gif" alt="" />
	</div>
	<div class="top_ad r">

	</div>
</div>

<!-- 导航 -->
<div class="menu">
	<span class="l">loong SSO 注册页面!</span>
	<span class="r">
		<a href="login.html">登录</a>
		<a href="reg.html">注册</a>		
	</span>
</div>
<div class="bottombg"></div>

<!-- 注册信息 -->
<div class="reg">

<form method="post" onsubmit="return disposal();" name="loginform">

	<div class="div_form">
		<div class="div1 l">注册用户名：</div>
		<div class="div2 l"><input class="div2_input" type="text" name="username" id="username" /></div>
		<div class="div3 l">3～20个合法字符(包括大小写字母、数字、下划线、中文)，一旦注册成功用户名不能修改。</div>
	</div>

	<div class="div_form">
		<div class="div1 l">接受相关协议：</div>
		<div class="div2 l">
			<label><input name="radiobutton" type="radio" value="radiobutton" checked="checked" />接受</label>&nbsp;&nbsp;
			<label><input type="radio" name="radiobutton" value="radiobutton" />不接受</label>		
		</div>
		<div class="div3 l f14px"><a href="">查看协议</a></div>
	</div>

	<div class="div_form">
		<div class="div1 l">注册密码：</div>
		<div class="div2 l"><input class="div2_input" name="password" type="password" id="password" /></div>
		<div class="div3 l">密码区分大小写，4～20个合法字符组成，请尽量使用英文字母加数字或符号的组合密码。</div>
	</div>

	<div class="div_form">
		<div class="div1 l">重复密码：</div>
		<div class="div2 l"><input class="div2_input" name="pass" type="password" id="pass" /></div>
		<div class="div3 l">请再输入一遍您上面输入的密码。</div>
	</div>

	<div class="div_form">
		<div class="div1 l">您的电子邮件：</div>
		<div class="div2 l"><input class="div2_input" name="email" type="text" id="email" /></div>
		<div class="div3 l">E-mail非常重要！这是我们与您联系的首选方式，以及接收我们的服务和取回密码的途径，请务必填写真实，并确认是您最常用的电子邮件。</div>
	</div>

	<div class="div_form">
		<div class="div1 l">验证码：</div>
		<div class="div4 l"><input class="div2_yzm" name="code" type="text" id="code" size="6" maxlength="4" autocomplete="off" /></div>
		<div class="div3 l"><img style="cursor:pointer" src="http://www.loongsso.com:7171/?module=validate" id="codeImg" name="codeImg" alt="看不清楚?请点击刷新" onclick="this.src='http://www.loongsso.com.com:7171/?module=validate&rand='+Math.random();"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;验证码不区分大小!</div>
	</div>

	<div class="div_form">
		<div class="div1 l">&nbsp;</div>
		<div class="div2 l">
			<label><input class="div2_submit" type="submit" id="Submit" name="sub" value="注 册" /></label>
			<label><input class="div2_submit" type="reset" name="Submit" value="重置" /></label>	
		</div>
		<div class="div3 l"></div>
	</div>

</form>

</div>





<!-- 版权 -->
<div class="footer">
	<p>版权所有：loongSSO</p>
	<p>技术支持：七夜(李锦星) lijinxing@gmail.com </p>
</div>



</body>
</html>